<!DOCTYPE html>
<html>
    <head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>{$reply['title']}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,user-scalable=yes;" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no" name="format-detection" />
    <meta content="email=no" name="format-detection" />
    <link href="../addons/stonefish_bigwheel/template/css/square.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="../addons/stonefish_bigwheel/template/js/WeixinApi.js"></script>
</head>
<style type="text/css">
#lottery table td.active{background-image:url({php echo toimage($reply['bigwheelimgbg'])});}
</style>
<body>
<div style="max-width:500px;">
    <div class="nou">
	    <div style="max-width:100%">
		{if !empty($reply['adpic'])}{if !empty($reply['adpicurl'])}<a href="{$reply['adpicurl']}">{/if}<img id="top_img" style="max-width: 100%;height: auto;width: auto\9;"  src="{php echo toimage($reply['adpic'])}" width="100%" border="0">{if !empty($reply['adpicurl'])}</a>{/if}{/if}
        </div>       
        <div class="zhuan1" id="lottery">
		    {if $reply['opportunity']==2}
			<div class="mingdan">
                <div class="biaoti">我的{$creditnames} <span class="n" id="credit_now">{php echo intval($credit[$reply['credit_type']])}</span> 个  每次 <span class="n">{$reply['credit_times']}</span> {$creditnames}</div>
            </div>
			{/if}
			{if $reply['opportunity']==1}
			<div class="mingdan">
                <div class="biaoti">{if !empty($msg)}{$msg}{else}赠送 <span class="n">{$reply['number_times']}</span> 次抽奖机会 剩余 <span class="n" id="number_times">{php echo $reply['number_times']-$fans['totalnum']}</span> 次{/if}</div>
            </div>
			{/if}
			{if $reply['opportunity']==0}
			<div class="mingdaninfo">
				<div class="box">					
					<div class="Detail" style="color:#FFF;text-align:center;">{$detail}</div>
				</div>
            </div>
			{/if}
            <table id="tb" style="max-width: 100%;background-color: #FD6830;" align="center;" >
                <tr>
					{php $i=0}
					{loop $prize0_3 $prizes0_3}
					<td class="playnormal lottery-unit lottery-unit-{$i}">
                        <div class="xx">
                            {if !empty($prizes0_3['prizepic'])}<img src="{php echo toimage($prizes0_3['prizepic'])}" />{/if}
                        </div>
                        {if empty($prizes0_3['prizepic'])}<div class="ee">{$prizes0_3['prizetype']}</div>{/if}
                    </td>
					{php $i++}
					{/loop}                    
                </tr>
				<tr>
                    <td class="playnormal lottery-unit lottery-unit-11">
                        <div class="xx">
                            {if !empty($prize11['prizepic'])}<img src="{php echo toimage($prize11['prizepic'])}" />{/if}
                        </div>
                        {if empty($prize11['prizepic'])}<div class="ee">{$prize11['prizetype']}</div>{/if}
                    </td>
                    <td></td>
                    <td></td>
                    <td class="playnormal lottery-unit lottery-unit-4">
                        <div class="xx">
                            {if !empty($prize4['prizepic'])}<img src="{php echo toimage($prize4['prizepic'])}" />{/if}
                        </div>
                         {if empty($prize4['prizepic'])}<div class="ee">{$prize4['prizetype']}</div>{/if}
                    </td>
                </tr>
                <tr>
                    <td class="playnormal lottery-unit lottery-unit-10">
                        <div class="xx">
                            {if !empty($prize10['prizepic'])}<img src="{php echo toimage($prize10['prizepic'])}" />{/if}
                        </div>
                         {if empty($prize10['prizepic'])}<div class="ee">{$prize10['prizetype']}</div>{/if}
                    </td>
                    <td></td>
                    <td></td>
                    <td class="playnormal lottery-unit lottery-unit-5">
                        <div class="xx">
                            {if !empty($prize5['prizepic'])}<img src="{php echo toimage($prize5['prizepic'])}" />{/if}
                        </div>
                         {if empty($prize5['prizepic'])}<div class="ee">{$prize5['prizetype']}</div>{/if}
                    </td>
                </tr>
                <tr>
                    {php $i=9}
					{loop $prize6_9 $prizes6_9}
					<td class="playnormal lottery-unit lottery-unit-{$i}">
                        <div class="xx">
                            {if !empty($prizes6_9['prizepic'])}<img src="{php echo toimage($prizes6_9['prizepic'])}" />{/if}
                        </div>
                         {if empty($prizes6_9['prizepic'])}<div class="ee">{$prizes6_9['prizetype']}</div>{/if}
                    </td>
					{php $i--}
					{/loop}
                </tr>
            </table>
            <div class="liji">                
                <a href="javascript:square()" id="btn"><span id="liji1" class="liji1" style="display:none">{$running}</span>
				<img id="liji2" class="liji2" src="{php echo toimage($reply['bigwheelimgan'])}" width="132" border="0" align="middle" /></a>
            </div>
			<div class="mingdan">
                <div class="biaoti">已有 <span class="n">{php echo $reply['xuninum']+$reply['fansnum']}</span> 人参与此活动</div>
            </div>
			{if !empty($award_list)&&$reply['awardnum']}
			<div class="mingdan">
                <div class="biaoti"><marquee behavior="scroll" scrolldelay="200">{$award_list}</marquee></div>
            </div>
			{/if}
			{if $share['sharenum']>0}
			<div class="boxwhite">
                <div id="shareimg" class="share"><img src="{$share['share_picurl']}"></div>
            </div>			
			{/if}
			<div style="height:55px;">&nbsp;&nbsp;</div>
        </div>
    </div>	
	<div class="panel-box" id="panel_box">
        <div class="panel-content" id="panel-content">
            <div class="panel-close" id="panel-close"></div>
            <span class="icon-prize-useless" id="panelimg"></span><br/><div id="cccc">{$reply['ticketinfo']}</div>
			<div id="result_info"{if !$isfans} style="display:none"{/if}>
			<div id="isfans" style="display:none">{$isfans}</div>
			    <hr class="common-hr" />              
                {if $reply['isrealname']}<label>{$isfansname[0]}</label><input name="text" class="px" id="realname" value="{$profile['realname']}" type="text" placeholder="请输入{$isfansname[0]}">{/if}
				{if $reply['ismobile']}<label>{$isfansname[1]}</label><input name="tel" class="px" id="mobile" value="{$profile['mobile']}" type="text" placeholder="请输入{$isfansname[1]}">{/if}
				{if $reply['isqq']}<label>{$isfansname[2]}</label><input name="tel" class="px" id="qq" value="{$profile['qq']}" type="text" placeholder="请输入{$isfansname[2]}">{/if}
				{if $reply['isemail']}<label>{$isfansname[3]}</label><input name="email" class="px" id="email" value="{$profile['email']}" type="text" placeholder="请输入{$isfansname[3]}">{/if}
				{if $reply['isaddress']}<label>{$isfansname[4]}</label><input name="text" class="px" id="address" value="{$profile['address']}" type="text" placeholder="请输入{$isfansname[4]}">{/if}
				{if $reply['isgender']}<label>{$isfansname[5]}</label><select name="gender" id="gender" class="form-control">
						<option value="0"{if $profile['gender']==0} selected {/if}>选择{$isfansname[5]}</option>
						<option value="1"{if $profile['gender']==1} selected {/if}>男</option>
						<option value="2"{if $profile['gender']==2} selected {/if}>女</option>
					</select>{/if}
				{if $reply['istelephone']}<label>{$isfansname[6]}</label><input name="text" class="px" id="telephone" value="{$profile['telephone']}" type="text" placeholder="请输入{$isfansname[6]}">{/if}
				{if $reply['isidcard']}<label>{$isfansname[7]}</label><input name="text" class="px" id="idcard" value="{$profile['idcard']}" type="text" placeholder="请输入{$isfansname[7]}">{/if}
				{if $reply['iscompany']}<label>{$isfansname[8]}</label><input name="text" class="px" id="company" value="{$profile['company']}" type="text" placeholder="请输入{$isfansname[8]}">{/if}
				{if $reply['isoccupation']}<label>{$isfansname[9]}</label><input name="text" class="px" id="occupation" value="{$profile['occupation']}" type="text" placeholder="请输入{$isfansname[9]}">{/if}
				{if $reply['isposition']}<label>{$isfansname[10]}</label><input name="text" class="px" id="position" value="{$profile['position']}" type="text" placeholder="请输入{$isfansname[10]}">{/if}
                <div id="result_info_tip"></div>
				<div class="btn-layout">
                    <input type="reset" class="btn-reset" value="重填"/>
					<input class="btn-confirm" name="确定" id="save-btn" type="button" value="确定">
                </div>
            </div>
			<div id="result_info1" style="display:none">
			    <div style="margin-top:10px;"><input class="btn-confirm" name="放入百宝箱" id="savebtn" type="button" value="放入百宝箱"> </div>
			</div>
			<div id="result_info2" style="display:none">
			    <div style="margin-top:10px;"><input class="btn-confirm" name="关闭" id="closebtn" type="button" value="关闭"> </div>
			</div>
        </div>
    </div>
	<div class="panel-box" id="share_box">
        <div class="panel-content" id="panel-content">
            <div class="panel-close" id="share_close"></div>
            <div id="share_tip"></div>
			<hr class="common-hr" />			
			<div style="margin-top:10px;" id="share_miao"><input class="btn-confirm" name="关闭" id="sharebtn" type="button" value="关闭"> </div>
        </div>
    </div>
</div>
{if $share['sharenum']>0}<div id="pop_share"><img src="{$share['share_pic']}" width="100%" alt="分享到朋友圈"/></div>{/if}
{template 'footer'}
<script type="text/javascript" src="../addons/stonefish_bigwheel/template/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">        
		$("#save-btn").bind("click",function () {
            var btn = $(this);
            {if $reply['isrealname']}
			var realname = $("#realname").val();
            if (realname == '') {
				$("#result_info_tip").text("请输入{$isfansname[0]}");
                return
            }
			var partten = /[\u4e00-\u9fa5]/g;
            if(!partten.test(realname)){
               $("#result_info_tip").text("请输入正确的{$isfansname[0]}");
			   return;
            }
			{/if}
			{if $reply['ismobile']}
			var mobile = $("#mobile").val();
            if (mobile == '') {
                $("#result_info_tip").text("请输入{$isfansname[1]}");
                return
            }
			var partten = /^1\d{10}$/;
            if(!partten.test(mobile)){
               $("#result_info_tip").text("请输入正确的{$isfansname[1]}");
			   return;
            }
			{/if}
			{if $reply['isqq']}
			var qq = $("#qq").val();
            if (qq == '') {
                $("#result_info_tip").text("请输入{$isfansname[2]}");
                return
            }			
            var partten = /^[1-9]{1}\d{4,11}$/;
            if(!partten.test(qq)){
               $("#result_info_tip").text("请输入正确的{$isfansname[2]}");
			   return;
            }
			{/if}
			{if $reply['isemail']}
			var email = $("#email").val();
            if (email == '') {
                $("#result_info_tip").text("请输入{$isfansname[3]}");
                return
            }
			var partten = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
            if(!partten.test(email)){
               $("#result_info_tip").text("请输入正确的{$isfansname[3]}");
			   return;
            }
			{/if}
			{if $reply['isaddress']}
			var address = $("#address").val();
            if (address == '') {
                $("#result_info_tip").text("请输入{$isfansname[4]}");
                return
            }
			{/if}
			{if $reply['isgender']}
			var gender = $("#gender").val();
            if (gender == '0') {
                $("#result_info_tip").text("请选择{$isfansname[5]}");
                return
            }
			{/if}
			{if $reply['istelephone']}
			var telephone = $("#telephone").val();
            if (telephone == '') {
                $("#result_info_tip").text("请输入{$isfansname[6]}");
                return
            }
			{/if}
			{if $reply['isidcard']}
			var idcard = $("#idcard").val();
            if (idcard == '') {
                $("#result_info_tip").text("请输入{$isfansname[7]}");
                return
            }
			{/if}
			{if $reply['iscompany']}
			var company = $("#company").val();
            if (company == '') {
                $("#result_info_tip").text("请输入{$isfansname[8]}");
                return
            }
			{/if}
			{if $reply['isoccupation']}
			var occupation = $("#occupation").val();
            if (occupation == '') {
                $("#result_info_tip").text("请输入{$isfansname[9]}");
                return
            }
			{/if}
			{if $reply['isposition']}
			var position = $("#position").val();
            if (position == '') {
                $("#result_info_tip").text("请输入{$isfansname[10]}");
                return
            }
			{/if}
            var submitData = {
                    code: $("#sncode").text(),
                    {if $reply['isrealname']}realname: realname,{/if}
					{if $reply['ismobile']}mobile: mobile,{/if}
					{if $reply['isqq']}qq: qq,{/if}
					{if $reply['isemail']}email: email,{/if}
					{if $reply['isaddress']}address: address,{/if}
					{if $reply['isgender']}gender: gender,{/if}
					{if $reply['istelephone']}telephone: telephone,{/if}
					{if $reply['isidcard']}idcard: idcard,{/if}
					{if $reply['iscompany']}company: company,{/if}
					{if $reply['isoccupation']}occupation: occupation,{/if}
					{if $reply['isposition']}position: position,{/if}
            };
           	$.post('{php echo $this->createMobileUrl('settel', array('rid' => $rid))}', submitData, function(data) {
			if (data.success == true) {
				$("#result_info").html("<br/><br/>" + data.msg + "<br/><div id='share_miao'>3秒后自动关闭</div>");
				djstime(3);
				setTimeout(function () {
				    $("#panel_box").hide();
					$("#result_info").hide();
					$("#isfans").text('0');
				},4000)
				return
			} else {
			    $("#result_info_tip").text(data.msg);
				return
			}
			},"json")
        });
		
var lottery={
	index:-1,	//当前转动到哪个位置，起点位置
	count:0,	//总共有多少个位置
	timer:0,	//setTimeout的ID，用clearTimeout清除
	speed:20,	//初始转动速度
	times:0,	//转动次数
	cycle:40,	//转动基本次数：即至少需要转动多少次再进入抽奖环节
	prize:-1,	//中奖位置
	init:function(id){
		if ($("#"+id).find(".lottery-unit").length>0) {
			$lottery = $("#"+id);
			$units = $lottery.find(".lottery-unit");
			this.obj = $lottery;
			this.count = $units.length;
			$lottery.find(".lottery-unit-"+this.index).addClass("active");
		};
	},
	roll:function(){
		var index = this.index;
		var count = this.count;
		var lottery = this.obj;
		$(lottery).find(".lottery-unit-"+index).removeClass("active");
		index += 1;
		if (index>count-1) {
			index = 0;
		};
		$(lottery).find(".lottery-unit-"+index).addClass("active");
		this.index=index;
		return false;
	},
	stop:function(index){
		this.prize=index;	
		return false;		
	}
};

function roll(){
	lottery.times += 1;
	lottery.roll();
	if (lottery.times > lottery.cycle+10 && lottery.prize==lottery.index) {
		clearTimeout(lottery.timer);
		lottery.prize=-1;
		lottery.times=0;
		click=false;
	}else{
		if (lottery.times<lottery.cycle) {
			lottery.speed -= 10;
		}else if(lottery.times==lottery.cycle) {
			lottery.prize = lottery.prizes;
			setTimeout(function () { 
                $("#panel_box").show();
				$("#credit_now").text(lottery.credit_now);
            }, 1500);
		}else{
			if (lottery.times > lottery.cycle && ((lottery.prize==0 && lottery.index==7) || lottery.prize==lottery.index+1)) {
				//lottery.speed += 110;
			}else{
				//lottery.speed += 20;
			}
		}
		if (lottery.speed<40) {
			lottery.speed=40;
		};
		//console.log(lottery.times+'^^^^^^'+lottery.speed+'^^^^^^^'+lottery.prize);
		lottery.timer = setTimeout(roll,lottery.speed);
		
	}
	return false;	
}

var click=false;

window.onload=function(){
	{if $isfans}
		$("#panel_box").show();
		$("#panel-content").css({"height": "{$isfansh}px"});
	{/if}
	lottery.init('lottery');
	$("#btn").click(function(){
	    if($("#isfans").text()==1){
		$("#panel_box").show();
		$("#panel-content").css({"height": "{$isfansh}px"});
	    }else{
		if (click) {
			return false;
		}else{
			$.getJSON('{php echo $this->createMobileUrl('get_award', array('rid' => $rid))}', function(data){
			    if(data.success==1) {
                    lottery.prizes = data.prizetype-1;
					lottery.credit_now = data.credit_now;
					$("#panelimg").css({"background-image": "url("+data.award['prizepic']+")"});
					if(data.award['credit_type']=='spaceprize'){
					    $("#cccc").text(data.award['prizetype']+"-"+data.award['prizename']+"-增送"+data.sn+"");
					}else{
					    $("#cccc").text(data.award['prizetype']+"-"+data.award['prizename']);
					}
					if($("#credit_now").length>0){
						$("#credit_now").text(parseInt($("#credit_now").text())-{$reply['credit_times']});
					}
					if($("#count").length>0){
						$("#count").text(parseInt($("#count").text())+1);
					}
					if($("#totalcount").length>0){
						$("#totalcount").text(parseInt($("#totalcount").text())+1)
					}
					if($("#number_times").length>0){
						$("#number_times").text(parseInt($("#number_times").text())-1);
					}
					lottery.speed=100;
			        roll();
			        click=true;
                }else{
                    $("#panelimg").css({"background-image": "url(../addons/stonefish_bigwheel/template/images/icon_prize_useless.png)"});
					$("#panel_box").show();
					$("#result_info1").hide();
					$("#cccc").text(data.msg);
					return false;
                }
				$("#panel-content").css({"height": ""+data.height+"px"});
				if(data.isfans){
					$("#result_info").show();
					$("#result_info1").hide();					
				}else{
					$("#result_info").hide();
					if(data.award['credit_type']=='spaceprize'){
					    $("#result_info2").show();
						$("#result_info1").hide();
				    }else{
					    $("#result_info1").show();
						$("#result_info2").hide();
					}					
				}				
			});				   
			return false;
		}
		}
	});	    
	$("#shareimg").click(function(){
		$("#pop_share").fadeToggle();
	});

	$("#pop_share").click(function(){
		$("#pop_share").fadeToggle();
	});
	$("#panel-close").click(function(){
		$("#panel_box").hide();
	});
	$("#savebtn").click(function(){
		$("#panel_box").hide();
	});
	$("#closebtn").click(function(){
		$("#panel_box").hide();
	});
	$("#share_close").click(function(){
		$("#share_box").hide();
	});
	$("#sharebtn").click(function(){
		$("#share_box").hide();
	});
};
// 需要分享的内容，请放到ready里
WeixinApi.ready(function(Api) {
	// 微信分享的数据
    var wxData = {
        "appId": "{$shareappid}", // 服务号可以填写appId
        "imgUrl" : '{$shareimg}',
        "link" : '{$sharelink}',
        "desc" : '{$sharedesc}',
        "title" : "{$sharetitle}"
    };

    // 分享的回调
    var wxCallbacks = {
        // 收藏操作是否触发回调，默认是开启的
        favorite : false,

        // 用async模式，表示每次分享之前，都需要更新分享内容
        async:true,

        {if !empty($share['share_cancel'])}
        // 分享被用户自动取消					
        cancel : function(resp) {
            // 你可以在你的页面上给用户一个小Tip，为什么要取消呢？
            $("#share_tip").text("{$share['share_cancel']}");
			$("#share_miao").text("5秒后自动关闭");
			$("#share_box").show();
			djstime(5);
			setTimeout(function () { 
                $("#share_box").hide();
            }, 6000);
        },
        {/if}
        {if !empty($share['share_fail'])}
        // 分享失败了
        fail : function(resp) {
            $("#share_tip").text("{$share['share_fail']}");
			$("#share_miao").text("5秒后自动关闭");
			$("#share_box").show();
			djstime(5);
			setTimeout(function () { 
                $("#share_box").hide();
            }, 6000);
        },
        {/if}
        {if !empty($share['share_confirm'])}
        // 分享成功
        confirm : function(resp) {
            // 分享成功了，我们是不是可以做一些分享统计呢？
			$.getJSON('{php echo $this->createMobileUrl('get_share', array('rid' => $rid,'from_user' => $page_from_user))}', function(data){
			    if(data.success==1) {
                    $("#share_tip").text("{$share['share_confirm']}");
			    }else{
			        $("#share_tip").text(data.msg);
			    }
			    $("#share_miao").text("5秒后自动关闭");
			    $("#share_box").show();
			    djstime(5);
			    setTimeout(function () { 
                    $("#share_box").hide();
                }, 6000);
			});
        },
        {/if}
    };

    // 用户点开右上角popup菜单后，点击分享给好友，会执行下面这个代码
    Api.shareToFriend(wxData, wxCallbacks);

    // 点击分享到朋友圈，会执行下面这个代码
    Api.shareToTimeline(wxData, wxCallbacks);

    // 点击分享到腾讯微博，会执行下面这个代码
    Api.shareToWeibo(wxData, wxCallbacks);

    // iOS上，可以直接调用这个API进行分享，一句话搞定
    Api.generalShare(wxData,wxCallbacks);
	
	//显示分享链接
	Api.showOptionMenu();
});
/*倒计时*/
function djstime(miao){
	var e1=$("#share_miao").first();
	var i=miao;
	var interval=setInterval(function(){
		e1.html(i+"秒自动关闭");
		$("#share_miao").css("line-height","35px");
		i--;
		if(i<0){
			$("#share_miao").css({cursor:"pointer"});
			$("#share_miao").css("line-height","18px");						
			clearInterval(interval);	
		}
	},1000);
}
</script>
</body>
</html>